<html>
<head>
<title>
  {% if puzzle.number %} #{{ puzzle.number }} {% endif %}
  {{ puzzle.title }} ({{ puzzle.key_name }})
  - {{ team.name }} - Iron Puzzler {{ game.location }}
</title>
<link rel="stylesheet" href="static/style.css">
</head><body><div class="pagecontent">

<h2>
  <a href="/">IP {{ game.location }}</a> &raquo;
  <a href="/team?t={{ team.key_id }}">{{ team.name }}</a> &raquo;
  Puzzle {% if puzzle.number %} #{{ puzzle.number }} {% endif %}
  ({{ puzzle.key_name }})
</h2>

<form action="{{ form_url }}" method="post" enctype="multipart/form-data">
<input type="hidden" name="t" value="{{ team.key_id }}">
<input type="hidden" name="p" value="{{ puzzle.number }}">

<h3>Title:
<input type="text" name="title" value="{{ puzzle.title }}" size=30></h3>

{% if game.results_enabled %}
  <h3>Comments</h3>
  {% for comment in comments %}
    {% if not forloop.first %}
      <p style="padding-left: 15px">&middot; &middot; &middot;</p>
    {% endif %}
    {{ comment|linebreaks }}
  {% empty %}
    <p>No comments were left for this puzzle.</p>
  {% endfor %}

  <h3>Votes</h3>
  <table>
    {% for scores in votes %}
      {% if forloop.first %}
        <tr> <td>Fun</td> <td>Pres.</td> <td>Ingr.</td> </tr>
      {% endif %}
      <tr> {% for score in scores %}
        <td align="center">{{ score }}</td>
      {% endfor %} </tr>
    {% empty %}
      <tr><td>No scores were entered for this puzzle.</td></tr>
    {% endfor %}
  </table>
{% endif %}

{% if solves %}
<h3>Solves</h3>
<table>
  {% for solve in solves|dictsort:"timestamp" %}
    <tr>
      <td>{{ forloop.counter }}. {{ solve.team.name }}</td>
      <td>{{ solve.timestamp|timesince }} ago</td>
    </tr>
  {% endfor %}
</table>
{% endif %}

<h3>Answers</h3>

<input type="hidden" name="answers.orig" value="{{ puzzle.answers|urlencode }}">
<textarea name="answers" wrap="off" cols="30" rows="5" class="leftside">
{{ puzzle.answers }}</textarea>
<p class="rightside">Correct answers to the puzzle, one per line.
Capitalization, punctuation, and spacing are ignored.</p>

<h3>Errata</h3>

<input type="hidden" name="errata.orig" value="{{ puzzle.errata|urlencode }}">
<textarea name="errata" cols="60" rows="6" class="leftside">
{{ puzzle.errata }}</textarea>
<p class="rightside">Notes to address last minute problems.
Visible to everyone.  Avoid spoilers!  Do not identify your team!</p>

<h3>Solution</h3>

<input type="hidden" name="solution.orig" value="{{ puzzle.solution|urlencode }}">
<textarea name="solution" cols="60" rows="15" class="leftside">
{{ puzzle.solution }}</textarea>
<p class="rightside">Complete walkthrough.
Visible to teams once they solve the puzzle or voting starts.
Do not identify your team!</p>

<h3>Uploads</h3>

<p>Please use PDF, JPEG, or a ZIP of PDF/JPEG files.</p>

<p style="margin-top: 1em">
  <label><b>Puzzle file</b>:
    {% if puzzle.puzzle_blob %}
      <a href="/download?p={{ puzzle.number|urlencode }}&t={{ team.key_id }}&f=p">
          {{ puzzle.puzzle_blob.filename|default:"file" }}</a>
      <br>Replace with:
    {% endif %}
    <input type="file" name="puzzle_file"><br>
    {% if puzzle.key_name == "paper" %}
      Upload the paper puzzle here.
    {% else %}
      You may upload an auxiliary file here.
    {% endif %}
    Everyone gets access when solving starts.
  </label>
</p>

<p style="margin-top: 1em">
  <label><b>Solution file</b>:
    {% if puzzle.solution_blob %}
      <a href="/download?p={{ puzzle.number|urlencode }}&t={{ team.key_id }}&f=s">
        {{ puzzle.solution_blob.filename|default:"file" }}</a>
      <br>Replace with:
    {% endif %}
    <input type="file" name="solution_file"><br>
    {% if puzzle.key_name == "paper" %}
      Upload the paper solution here.
    {% else %}
      You may upload additional solution material here (eg. a photo).<br>
    {% endif %}
    Teams get access once they solve the puzzle or start voting.
  </label>
</p>

<p><em>Note!</em> Don't forget to bring physical copies as required by your
local coordinator!</p>

<h3><button type="submit">Submit changes</button></h3>
</form>
</div></body></html>  <!-- end .pagecontent -->
